﻿<link href="@Url.Content("~/content/activitie_detail.css")" rel="stylesheet" type="text/css"/>

<!--[if !IE]> -->
    <link rel="stylesheet" href="@Url.Content("~/plugin/accordion/demo.css")">
    <script>document.documentElement.className = "js";</script>
    <script src="@Url.Content("~/plugin/accordion/json2.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_storage.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_cookie_storage.js")"></script>
<!-- <![endif]-->

<!--[if gte IE 8]>
    <link rel="stylesheet" href="@Url.Content("~/plugin/accordion/demo.css")">
    <script>document.documentElement.className = "js";</script>
    <script src="@Url.Content("~/plugin/accordion/json2.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_storage.js")"></script>
    <script src="@Url.Content("~/plugin/accordion/jquery.collapse_cookie_storage.js")"></script>
<![endif]-->


@model PessModel.Archive

@{
    ViewBag.Title = "档案详细";

    bool hideArchiveDetails = false;
    hideArchiveDetails = Roles.IsUserInRole("ExpertJudge")
        && ViewBag.HideArchiveDetails != null
        && ViewBag.HideArchiveDetails == true;
}
 
<div id="m-title">
    <h2>档案及评分<span> > 详细</span></h2>
    @*<div>@Html.ActionLink("编辑申报表", "Edit", "Archive", new {id=Model.ID },null)</div>*@
    <div id="m-op">
        @if (Roles.IsUserInRole("Admin"))
        {
            @Html.ActionLink("补填分数", "EditScores2", "Score", new { archiveID = Model.ID }, null)
        }
        @if ((bool)ViewBag.IsArchiveModificationAllowed)
        {
            if (Roles.IsUserInRole("Admin") || Roles.IsUserInRole("CountyAdmin")||Utility.IsUserAuthor(Model))
            {
                <span>&#8195; </span>@Html.ActionLink("编辑申报表", "Edit", "Archive", new { id = Model.ID }, new {  @class = "f-btn-long" })
            }
        }
        &#8195; @Html.ActionLink("评审意见", "Feedback", "Archive", new { serialNumber = Model.SerialNumber }, null)
        &#8195; @Html.ActionLink("历史档案", "PreviousArchives", "Archive", new { archiveID = Model.ID }, null)&#8195;@Html.ActionLink("返回", "Index", new { activityID = Model.Subject.ActivityID, archiveID = Model.ID }, null)
    </div>
</div>


<div id="custom-show-hide-example">
    <h3> 申报表（@Html.DisplayFor(model => model.ProjectTitle)） </h3>
    <div>
        @*<div class="displayPic">
            @Html.PhotoImage(string.Format("~/uploads/{0}/{1}/",Model.Subject.ActivityID,Model.ID)+Model.PhotoUrl)
        </div>*@

        <div class="displayDesc">
            活动： @Html.DisplayFor(model => model.Subject.Activity.Name)
        </div>
        <div class="displayDesc">
            @*@ViewBag.ArchiveSerialNumberDisplayName：*@
            @Html.DisplayNameFor(model => model.SerialNumber)：@Html.DisplayFor(model => model.SerialNumber)
        </div>
        @if(false){//consider make its visibility switchable.
        <div class="displayDesc">
            @*@ViewBag.ArchiveSubjectNameDisplayName*@
            @Html.DisplayNameFor(model => model.PreviousSN)： @Html.DisplayFor(model => model.PreviousSN)
        </div>
        }

        <div class="displayDesc">
            <span class="eWidth">学科</span>组： @Html.DisplayFor(model => model.Subject.Name)&#8195;
        </div>
        <div class="displayDesc">
            @*@ViewBag.ArchiveCountyNameDisplayName*@ 
            @Html.DisplayNameFor(model => model.CountyCode)： @Html.DisplayFor(model => model.County.Name) 
        </div>
        @if (!hideArchiveDetails)
        {
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "SchoolName"))
            {
            <div class="displayDesc">
                @*@ViewBag.ArchiveSchoolNameDisplayName*@
                @Html.DisplayNameFor(model => model.SchoolName)： @Html.DisplayFor(model => model.SchoolName), 地址：（@Html.DisplayFor(model => model.SchoolAddress)）
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "TeacherName"))
            {
            <div class="displayDesc">
                @*@ViewBag.ArchiveTeacherNameDisplayName*@
                @Html.DisplayNameFor(model => model.TeacherName)：@Html.DisplayFor(model => model.TeacherName)
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "EducationDegree"))
            {
             <div class="displayDesc">
                @*学历*@
                 @Html.DisplayNameFor(model => model.EducationDegree)： @Html.DisplayFor(model => model.EducationDegree)
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "YearsofTeachings"))
            {
            <div class="displayDesc">
                @*教龄*@
                @Html.DisplayNameFor(model => model.YearsofTeachings)： @Html.DisplayFor(model => model.YearsofTeachings)
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "ProfessionalTitle"))
            {
            <div class="displayDesc">
                @*职称*@
                @Html.DisplayNameFor(model => model.ProfessionalTitle)： @Html.DisplayFor(model => model.ProfessionalTitle)
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "ProjectMembers"))
            {
            <div class="displayDesc">
                @*课题组成员*@
                @Html.DisplayNameFor(model => model.ProjectMembers)： @Html.DisplayFor(model => model.ProjectMembers)
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "GradeLevel"))
            {
            <div class="displayDesc">
                @*年级*@
                @Html.DisplayNameFor(model => model.GradeLevel)： @Html.DisplayFor(model => model.GradeLevel) 年级
            </div>                
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "SchoolComment"))
            {
            <div class="displayDesc">
                @*学校评语*@
                @Html.DisplayNameFor(model => model.SchoolComment)： @Html.Raw(Model.SchoolComment)
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "CountyEBComment"))
            {
            <div class="displayDesc">
                @*区县评语*@
                @Html.DisplayNameFor(model => model.CountyEBComment)： @Html.Raw(Model.CountyEBComment)  
            </div>
            }
            if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "AuthorSN"))
            {
            <div class="displayDesc">
                @*作者帐号*@
                @Html.DisplayNameFor(model => model.AuthorSN)： @Html.DisplayFor(model => model.AuthorSN)  
            </div>
            }
            if (ViewBag.IsScheduledDateEnabled)
            {
            <div class="displayDesc">
                @Html.DisplayNameFor(model => model.ScheduledDate)： @Html.DisplayFor(model => model.ScheduledDate)
            </div>
            <div class="displayDesc">
                @Html.DisplayNameFor(model => model.DrivingDirections)： @Html.DisplayFor(model => model.DrivingDirections)
            </div>
            }
            if (((Roles.IsUserInRole(Membership.GetUser().UserName, "Admin") /*Only admin need to contact author.*/
                        || Roles.IsUserInRole(Membership.GetUser().UserName, "CountyAdmin"))))
            {
                if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "AuthorSSID"))
                {
                <div class="displayDesc">
                    @Html.DisplayNameFor(model => model.AuthorSSID)： @Html.DisplayFor(model => model.AuthorSSID)
                </div>
                }
                if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "MailAddress"))
                {
                <div class="displayDesc">
                    @Html.DisplayNameFor(model => model.MailAddress)： @Html.DisplayFor(model => model.MailAddress)
                </div>
                }
                if (Html.CheckVisibility((IEnumerable<PessModel.ArchiveDisplayName>)ViewBag.ArchiveDisplayNames, "PhoneNumber"))
                {
                <div class="displayDesc">
                    @*电话*@
                    @Html.DisplayNameFor(model => model.PhoneNumber)： @Html.DisplayFor(model => model.PhoneNumber)
                </div>
                }
            }
        }

    </div>
            

                    <h3 class="open"> 附件</h3>
    <div>
<p style="display:none;">
    @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
    @Html.ActionLink("Back to List", "Index")
</p>

<div style="display:none;">
    @Html.Partial("UploadAttachment", Model.ID)
</div>

@section Styles{
    <link href="@Href("~/Content/uploadify.css")" rel="stylesheet" />
}

            @section JavaScript{
    <script src="@Href("~/Scripts/jquery.uploadify.js")" type="text/javascript"></script>
    <script type="text/javascript">
        var archiveID=@Model.ID
        $(function () {
            $('#file_upload').uploadify({
                        'fileSizeLimit':0,
                'swf': '@Url.Content("~/Scripts/uploadify.swf")',
                'uploader': '@Url.Content("~/Archive/Upload")',
                'auto': true,
                'fileSizeLimit': 0,
                'multi': true,
                'formData': {'archiveID':archiveID},
                'buttonText': '上传附件',
                'cancelImg': '@Url.Content("~/images/uploadify-cancel.png")',
                'onQueueComplete' : function(file, data, response) {
                            //alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
                            location.reload(true);
                        }
                    });
                });
    </script>


}
@if (((Roles.IsUserInRole(Membership.GetUser().UserName, "Admin")
    || Roles.IsUserInRole(Membership.GetUser().UserName, "CountyAdmin")
    || Roles.IsUserInRole(Membership.GetUser().UserName, "Author"))
    && (bool)ViewBag.IsArchiveModificationAllowed))
{
<input type="file" name="file_upload" id="file_upload" />
}
        <div id="showFile" class="displayFile">
        @{
            var grid = new WebGrid(Model.Attachments, defaultSort: "Title");
        }
        @grid.GetHtml(columns: from c in grid.Columns(
                 grid.Column("Title", header: " 文件名 ", format: @<text>@Html.ActionLink((string)item.Title, "Download", "Archive", new { archiveID = Model.ID, title = (string)item.Title }, null)</text>,style:"thAction2"),
                 grid.Column("FileSize", header: " 文件大小（KB） "),
                 grid.Column("TimeStamp", header: " 最后修改时间 "),
                 grid.Column("Operation", header: "操作", format: @<text>@if ((bool)ViewBag.IsArchiveModificationAllowed) { @Html.ActionLink("删除", "DeleteAttachment", "Archive", new { archiveID = Model.ID, title = (string)item.Title }, null); }</text>,style:"thAction")
             )
                        where !c.ColumnName.Contains("Operation") || (Roles.IsUserInRole("Admin") || Roles.IsUserInRole("CountyAdmin")|| Roles.IsUserInRole("Author"))
                        select c
        )
        </div>
        <br />
</div>

@if (Roles.IsUserInRole(Membership.GetUser().UserName, "ExpertJudge"))
{

        <h3 class="open"> 评分</h3>
    <div>
        <div id="scores" class="displayConScroe">
            @Html.Action("ArchiveExpertScores", "Score", new { archiveID = Model.ID })
        </div>
        <br />
        @if (ViewBag.IsScoreInputAllowed)
        {
            <div id="scoreButtons" style="display:none">
                <span id="editScoresBtn" class="asBtn" >评分</span>
                <span id="deleteScoresBtn" class="asBtn" >删除分数</span>
                <span id="saveScoresBtn" class="asBtn">保存</span>
                <span id="cancelBtn" class="asBtn">取消</span>
            </div>
            @Html.ActionLink("评分", "EditScores2", "Score", new { archiveID = Model.ID }, new { id = "editScoresBtn2" })
        }

    </div>
}

</div>

 <script type="text/javascript">
     $("#scoreButtons").show();
     $("#saveScoresBtn").hide();
     $("#cancelBtn").hide();

     $("#editScoresBtn2").hide();

     function getInternetExplorerVersion()
         // Returns the version of Internet Explorer or a -1
         // (indicating the use of another browser).
     {
         var rv = -1; // Return value assumes failure.
         if (navigator.appName == 'Microsoft Internet Explorer') {
             var ua = navigator.userAgent;
             var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
             if (re.exec(ua) != null)
                 rv = parseFloat(RegExp.$1);
         }
         return rv;
     }
     function checkVersion() {
         var msg = "You're not using Internet Explorer.";
         var ver = getInternetExplorerVersion();
         var expectedver = 10.0;

         if (ver > -1) {
             if (ver >= expectedver)
                 msg = "You're using a recent copy of Internet Explorer."
             else {
                 //alert("您的浏览器版本较低，建议使用IE8.0以上浏览器。");
                 $('#scoreButtons').hide();
                 $("#editScoresBtn2").show();
             }
         }
        
     }
     checkVersion();


     var archiveID=@Model.ID;
        $.ajaxSetup({cache:false});
        $("#editScoresBtn").click(function () {
            //$("#scoreField").each(function () {
            //    alert($(this).val());
            //});
            //alert("Edit Scores");
           
            $.get("/score/EditScores", { "archiveID": archiveID },function (data)
            {
                //alert(status);
                //alert(data);
                $("#scores").html(data);
            });

            $("#saveScoresBtn").show();
            $("#cancelBtn").show();

        });
    
        $("#saveScoresBtn").click(function () {
            $("#scores input[type=text]").each(function () {
                ////alert($(this).prop('id')+","+$(this).val());
                //$.post("/Score/Edit",{RuleID:$(this).prop('id'),ArchiveID:archiveID,Value:$(this).val()},function(data){
                //}).fail(function(){alert("error posting.");});

                $.ajax({
                    type:"POST",
                    url:"/Score/Edit",
                    contentType:"application/json; charset=utf-8",
                    data: JSON.stringify({
                        RuleID: $(this).attr('id'),
                        ArchiveID:archiveID,
                        Value:$(this).val()
                    }),
                    error: function (result) {
                        alert(result)
                    }
                });
                
                $("#saveScoresBtn").hide();
                $("#cancelBtn").hide();

                $.get("/score/ArchiveExpertScores", { "archiveID": archiveID },function (data)
                {
                    $("#scores").html(data);
                });
            });
        });

        $("#cancelBtn").click(function () {
                $.get("/score/ArchiveExpertScores", { "archiveID": archiveID },function (data)
                {
                    $("#scores").html(data);
                });
                $("#cancelBtn").hide();
                $("#saveScoresBtn").hide();
        });

        $("#deleteScoresBtn").click(function(){
            $.ajax({
                type:"POST",
                url:"/Score/DeleteScores",
                contentType:"application/json; charset=utf-8",
                data: JSON.stringify({
                    ArchiveID:archiveID
                }),
                error: function (result) {
                    alert(result)
                }
            });
            $.get("/score/ArchiveExpertScores", { "archiveID": archiveID },function (data)
            {
                $("#scores").html(data);
            });
            $("#cancelBtn").hide();
            $("#saveScoresBtn").hide();
        });
    </script>

@*<script language="javascript">
    for (i=0;i< document.getElementsByTagName("table").length;i++){
        document.getElementsByTagName("table")[i].className = "oddTable";
    }
</script>*@
@*<p>@Html.Action("EditScores","Score",new {archiveID=Model.ID})</p>*@

@*<script>
    $(document).ready(function(){
        $(".help h3").click(function(){ 
            $(this).next("p").slideToggle("fast").siblings("p:visible").slideUp("fast");  
        });
    });
</script>*@

<!--[if !IE]> -->
      <script>
          new jQueryCollapse($("#custom-show-hide-example"), {
              open: function() {
                  this.slideDown(150);
              },
              close: function() {
                  this.slideUp(150);
              }
          });
      </script>
<!-- <![endif]-->

<!--[if gte IE 8]>
      <script>
          new jQueryCollapse($("#custom-show-hide-example"), {
              open: function() {
                  this.slideDown(150);
              },
              close: function() {
                  this.slideUp(150);
              }
          });
      </script>
<![endif]-->
